package org.vnl.platform.job;

import java.text.DecimalFormat;

import org.vnl.platform.dk.util.SEVERITY;

/**
 * 執行Job時會發生的錯誤代碼
 * 
 * @author Vaughan
 *
 */
public enum JobErrCode {

    /**
     * 設定Job Engine的Metadata有誤 param 0:-> metadata xml 
     */
    INIT_JOB_ENGINE_ERR(SEVERITY.ERROR), 
    /**
     * 產生Job的實體有誤 param 0:-> job class name
     */
    CREATE_JOB_ERR(SEVERITY.ERROR),
    /**
     * Job的類別錯誤,沒有實作IJob param 0:-> job class name
     */
    JOB_TYPE_ERR(SEVERITY.ERROR),
    /**
     * Job在讀取設定時錯誤 0:->設定參數名
     */
    LOADING_JOB_SETTING_ERR(SEVERITY.ERROR)
    ;
    
    SEVERITY severity;
    
    JobErrCode(SEVERITY severity) {
        this.severity = severity;
    }
    
    @Override
    public String toString() {
        StringBuffer sb = new StringBuffer("JOB_");
        DecimalFormat df = new DecimalFormat("0000");
        sb.append(df.format(this.ordinal()));
        return sb.toString();
    }
    
    public String getSeverityString() {
        return this.severity.toString();
    }
    
    public SEVERITY getSeverity() {
        return this.severity;
    }
 
    public static void main(String[] args) throws Exception {
        JobErrCode[] codes = JobErrCode.values();
        for (int ii = 0; ii < codes.length; ii++) {
            System.out.println("#" + codes[ii].name());
            System.out.println(codes[ii].toString() + "=\n");
        }
    }
}
